package com.zhouyu.mybatis.spring;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.BeanFactoryPostProcessor;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.stereotype.Component;

@Component
public class CustomSupplierBeanFactoryPostProcessor implements BeanFactoryPostProcessor {
	@Override
	public void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException {
			AbstractBeanDefinition beanDefinition = (AbstractBeanDefinition) beanFactory.getBeanDefinition("customInstantiationAwareBeanPostProcessor");
			beanDefinition.setInstanceSupplier(()-> new CustomInstantiationAwareBeanPostProcessor());
			System.out.println("do Custom Supplier BeanFactoryPostProcessor");
	}
}
